class WebsitestasksController < ApplicationController
before_filter :authorize
    layout "page"
 
      active_scaffold :websitesinf do |config|
  config.label = "Websites List"
config.show.link.label = "Show Detail"  
config.show.link.type = :record
config.show.link.inline = true
  config.show.link.position = :after 
 config.actions.exclude :create,:update,:delete
 #   config.columns = [:name,:editorname1,:seditorname1]
  	  config.columns = [:iscurrent,:name,:description1,:url1,:editorname1,:seditorname1,:mission1,:ecweekly1,:last_accessed_at,:last_accessed_user,:last_updated_at,:last_updated_user]	
  config.list.columns.exclude :description1, :url1, :mission1, :ecweekly1 	

# config.actions.swap :search, :live_search
     config.columns[:iscurrent].label ="Set As Default"
		 config.columns[:name].label ="Website Name"
		 config.columns[:description1].label ="Website Description"
		 config.columns[:url1].label ="Website URL"
		 config.columns[:editorname1].label ="Name of Editor"	  	 
		 config.columns[:seditorname1].label ="Name of Sub Editor"
		 config.columns[:mission1].label ="Website mission"	  	 
		 config.columns[:ecweekly1].label ="Editors weekly comment"	

 	  config.columns[:iscurrent].inplace_edit = true 

 config.action_links.add 'index', :label => 'Articles List', :type => :record,:page=>true,:parameters =>{:controller=>'websitearticles'}
#columns[:articles].set_link('nested', :parameters => {:associations => :articles,:websiteid=>params[:id]})

#		    config.nested.add_link("Articles List", [:articles]) 
#   		 config.columns[:articles].search_sql = "CONCAT(articles.title,articles.synopsis,artilces.body,articles.user_published_by)"    
#		 config.search.columns << :articles  
		 
    config.columns[:description1].form_ui = :textarea
    config.columns[:description1].options = {:rows => 90, :cols => 150}


    config.columns[:ecweekly1].form_ui = :textarea
    config.columns[:ecweekly1].options = {:rows => 90, :cols => 150}
    

    config.subform.columns.exclude :description1, :url1, :mission1, :ecweekly1

    
       	


    config.show.columns.exclude(:iscurrent,:name,:editorname1,:seditorname1)       	
  config.show.label = "Show Detail"

# config.subform.columns = [:description1, :url1, :mission1, :ecweekly1] config.subform.columns = [:name1,:editorname1,:seditorname1]
		 
  end

  def show
  super
 # redirect_to  :controller => 'index'
 # return
    @websitesinf = Websitesinf.find(params[:id])
    @websitesinf.last_accessed_user = User.find(session[:user_id]).name
    @websitesinf.last_accessed_at = Time.now
    @websitesinf.save
   #  redirect_to  :controller => 'websitesinfs',:action=>'show'
  end


  def mytest
  @all_articles = Article.find(:all)
    @websitesinf = Websitesinf.find(params[:id])
  end

  def mytest0


    @websit=Websitesinf.find(params[:id])
    @myteststr = "Articles List For Website "+@websit.name
    redirect_to :controller=>'websitearticles',:action=>'index',:websiteid=>params[:id],:varaaa=>@myteststr

  end   

  
  def mytest1
    @websit=Websitesinf.find_by_iscurrent(true)
    @myteststr = "Articles List For Website "+@websit.name
    redirect_to :controller=>'websitearticles',:action=>'index',:id=>@websit.id
  end 
  
  def mytest2
    @websit=Websitesinf.find_by_iscurrent(true)
    @myteststr = "Articles List For Website "+@websit.name
    redirect_to :controller=>'websitearticles2',:action=>'index',:id=>@websit.id
  end    

  def setdefws
   Websitesinf.find(:all).each do |myobj|
   	myobj.iscurrent = false
   	myobj.save

   end
      @websit=Websitesinf.find(params[:id])
      @websit.iscurrent = true
      @websit.save
  end
end
